<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/4/12
 * Time: 16:35
 */
require __DIR__.'/../../vendor/autoload.php';

use Io\Signal\Worker;

$woker = new Worker('tcp://0.0.0.0:9001');

$woker->onConnect = function ($socket, $client = null) {
    echo '有一个链接'.PHP_EOL;
};

$woker->onReceive = function ($socket, $client, $data) {
    echo '给链接发信息是'.PHP_EOL;
    //sleep(4);
    $socket->send($client, '1hello world client');
};

$woker->start();